#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Agresso.Interface.Layer.Service;
using System.Collections;
using Agresso.Interface.Layer.Domain;

#endregion

namespace Agresso.Interface.Layer.Web
{
    public partial class SoftmarProformaExecuteForm : Form
    {
        CommissionInvoiceService m_CommissionInvoiceService;
        IList m_commissionProforma;
        public SoftmarProformaExecuteForm(IList commissionProforma)
        {
            m_CommissionInvoiceService = new CommissionInvoiceService();
            m_commissionProforma = commissionProforma;
            InitializeComponent();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonExecute_Click(object sender, EventArgs e)
        {
            m_CommissionInvoiceService.SetTestDateProforma(false, DateTime.Today, DateTime.Today, dateTimePickerPeriod.Value);
            foreach (CommissionInvoice ci in m_commissionProforma)
            {
                if (ci.invoice_type == "Commission Credit")
                    m_CommissionInvoiceService.ExecuteInvoiceProformaCommissionCredit(ci);
                else if (ci.invoice_type == "Charge Credit")
                    m_CommissionInvoiceService.ExecuteInvoiceProformaChargeCredit(ci);
                else if (ci.invoice_type == "Charge Debit")
                    m_CommissionInvoiceService.ExecuteInvoiceProformaChargeDebit(ci);
                ci.remarks = "1";// for indicate is done
            }

            //if (dateTimePickerTo.Value < dateTimePickerFrom.Value)
            //{
            //    MessageBox.Show("To Date can not be greater than From Date");
            //    return;
            //}
            
            //m_CommissionInvoiceService.ExecuteInvoiceProformaCommissionCredit();
           // m_CommissionInvoiceService.ExecuteInvoiceProformaChargeCredit();
           // m_CommissionInvoiceService.ExecuteInvoiceProformaChargeDebit();
            MessageBox.Show("Execute Done", new EventHandler(buttonCancel_Click));
        }


    }
}